﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel.Models
{
    public class UserModel
    {
        public Guid ID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string FamilyName { get; set; }
        public string Email { get; set; }
        public string Login { get; set; }
        public string Password { get; set; }
        public TypeOfUser Type { get; set; }

        public ProfileModel Profile { get; set; }
        public List<RoleModel> Roles { get; set; }

        public UserModel() { }

        public UserModel(User user)
        {
            ID = user.ID;
            LastName = user.lastName;
            FirstName = user.firstName;
            FamilyName = user.familyName;
            Email = user.email;
            Login = user.login;
            Password = user.password;
            Roles = new List<RoleModel>();
            foreach (var r in user.Roles)
            {
                Roles.Add(new RoleModel() { Name = r.name , ID = r.ID});
            }
            //Select type of user
            Type = (user.Students.Count != 0) ? TypeOfUser.Student : (user.Admins.Count != 0) ? TypeOfUser.Admin : TypeOfUser.Professor;
        }

        public override string ToString()
        {
            return string.Format("{0} {1}", LastName, FirstName);
        }
    }
}
